
#include <algorithm>
#include <cctype>
#include <chrono>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

#include "common/person.h"

auto predicate = [limit = 18]<typename T>(T&& object) { return object.age() > limit; };

int main()
{
    std::vector<person_t> people {
        { "David", "", person_t::male, 15 },
        { "Jane", "", person_t::female, 18 },
        { "Martha", "", person_t::female, 19 },
        { "Peter", "", person_t::male, 20 },
        { "Rose", "", person_t::female, 13 },
        { "Tom", "", person_t::male, 12 }
    };
    // auto cnt = std::count_if(people.cbegin(), people.cend(), predicate);
    auto cnt = std::count_if(people.cbegin(), people.cend(), [limit = 18]<typename T>(T&& object) { return std::forward<decltype(object)>(object).age() >= limit; });
    std::cout << "count: " << cnt << std::endl;

    // int count = 0;
    // std::string name = "Wayne";
    // std::vector<std::string> words { "An", "ancient", "pond" };
    // std::for_each(words.cbegin(), words.cend(),
    //     [&count, name = std::move(name), time = std::chrono::high_resolution_clock::now().time_since_epoch().count()](const std::string& word) mutable {
    //     std::cout << time << " : " << name << std::endl;
    //     if (isupper(word[0])) {
    //     ++count;
    // } });
    // std::cout << "count: " << count << ", name: " << name << std::endl;

    return 0;
}